/*
     C++上机作业
     编写一个程序，用同一个函数名对n个数据进行从小到大排序，数据类型可以是整型、单精度型、双精度型。用函数重载实现

     夏思成

     2024年3月17日
*/

#include <iostream>
using namespace std;

//函数重载
void sort(int& a, int& b, int& c)
{
    int tmp = 0;
    if (a > b)
    {
        tmp = a;
        a = b;
        b = tmp;
    }

    if (a > c)
    {
        tmp = a;
        a = c;
        c = tmp;
    }

    if (b > c)
    {
        tmp = b;
        b = c;
        c = tmp;
    }
}

void sort(float& a, float& b, float& c)
{
    float tmp = 0;
    if (a > b)
    {
        tmp = a;
        a = b;
        b = tmp;
    }

    if (a > c)
    {
        tmp = a;
        a = c;
        c = tmp;
    }

    if (b > c)
    {
        tmp = b;
        b = c;
        c = tmp;
    }
}

void sort(double& a, double& b, double& c)
{
    double tmp = 0;
    if (a > b)
    {
        tmp = a;
        a = b;
        b = tmp;
    }

    if (a > c)
    {
        tmp = a;
        a = c;
        c = tmp;
    }

    if (b > c)
    {
        tmp = b;
        b = c;
        c = tmp;
    }
}

int main()
{
    int a = 0;
    int b = 0;
    int c = 0;
    float d = 0.0;
    float e = 0.0;
    float f = 0.0;
    double g = 0.0;
    double h = 0.0;
    double i = 0.0;
    cout << "请分别输入三个整型，单精度浮点型，双精度浮点型：" << endl;
    cin >> a >> b >> c;
    cin >> d >> e >> f;
    cin >> g >> h >> i;
    sort(a, b, c);
    sort(d, e, f);
    sort(g, h, i);
    cout << "排序后：" << endl;
    cout << a << " " << b << " " << c << endl;
    cout << d << " " << e << " " << f << endl;
    cout << g << " " << h << " " << i << endl;
    return 0;
}